#ifndef __LOGGER_H__
#define __LOGGER_H__

#pragma once

#include "NezhaMemory.h"

#define MAX_NEZHA_LOGGER_BUFFER 4096

namespace Nezha
{

	class LoggerOutput;

	class NEZHA_ENGINE_ENTRY Logger
	{
	public:
		static void Debug(const char* str, ...);

		static void Log(const char* info, ...);

		static void Warning(const char* warning, ...);

		static void Error(const char* err, ...);

		// post log to specify output.
		static void Debug2(int outputFlag, const char* str, ...);

		static void Log2(int outputFlag, const char* info, ...);

		static void Warning2(int outputFlag, const char* warning, ...);

		static void Error2(int outputFlag, const char* err, ...);

		enum Level
		{
			LL_DEBUG = 0,
			LL_INFO,
			LL_WARNING,
			LL_ERROR,
			LL_NONE
		};

		enum OutputType
		{
			CONSOLE = 0x1,
			FILE = 0x2,
			TOOL_WINDOW = 0x4,
			NETWORK = 0x8,
			DATABASE = 0x10,

			// extra
			FILE_EX1 = 0x20,
			FILE_EX2 = 0x40,
			FILE_EX3 = 0x80,
			FILE_EX4 = 0x100,

			// limit
			MAX_OUTPUT_TYPE = 16
		};

		static void SetLoggerOutput(OutputType ot, LoggerOutput* lo);

		// flag combined by OutputType
		static void SetOutputFlag(int flag);

		static int GetOutputFlag();

		static void SetLoggerFilter(Level filter);

	};

	class NEZHA_ENGINE_ENTRY LoggerOutput
	{
	public:
		virtual ~LoggerOutput(){}

		virtual void post(const String& str, Logger::Level) = 0;
	};

// shotcut macro to replace
#define NZDebug Logger::Debug
#define NZLog Logger::Log
#define NZWarning Logger::Warning
#define NZError Logger::Error
#define NZDebug2 Logger::Debug2
#define NZLog2 Logger::Log2
#define NZWarning2 Logger::Warning2
#define NZError2 Logger::Error2

#define NZ_SOURCE_TRACK(desc) "##desc : %s, %d", __FILE__, __LINE__

}//end namespace Nezha

#endif //end __LOGGER_H__